#ifndef _VECTOR4
#define _VECTOR4

// INCLUDES --------------------------------------------------------------------
#include "Base.h"

// DEFINES ---------------------------------------------------------------------

// TYPEDEFS --------------------------------------------------------------------
typedef struct // 3D cartesian
{
  union
  {
    fp32 x, y, z, w; // component style
    fp32 v[4];       // array style
  };
} Vector4;

// FUNCTIONS -------------------------------------------------------------------

/* GENERAL:
   d    -> destination
   s    -> source
   size -> array size (0,1 for single elements)

   a,b  -> two arbitrary vertices
   k    -> floating point scalar
*/
void V4Clear(Vector4 *v, ui32 size);                // clear to [0,0,0,1]
void V4Copy (Vector4 *d, Vector4 *s, ui32 size);    // clone vector src->dest

fp32 V4Magnitude(Vector4 *v);                       // vector magnitude
void V4Normalize(Vector4 *v);                       // normalize to [0.0f, 1.0f]
void V4Invert   (Vector4 *v);                       // -(v)

fp32 V4ScalarP(Vector4 *a, Vector4 *b);             // scalar product
void V4VectorP(Vector4 *d, Vector4 *a, Vector4 *b); // vector product

void V4Add  (Vector4 *d, Vector4 *a, Vector4 *b);   // +
void V4AddTo(Vector4 *d, Vector4 *a);               // +=

void V4Sub  (Vector4 *d, Vector4 *a, Vector4 *b);   // -
void V4SubTo(Vector4 *d, Vector4 *a);               // -=

void V4Mul  (Vector4 *d, Vector4* a, fp32 k);       // *
void V4MulTo(Vector4 *d, fp32 k);                   // *=

void V4Div  (Vector4 *d, Vector4* a, fp32 k);       // /
void V4DivTo(Vector4 *d, fp32 k);                   // /=

bool V4Equals  (Vector4 *a, Vector4 *b);            // ==
bool V4InEquals(Vector4 *a, Vector4 *b);            // !=

#endif // _VECTOR4
